import { defineConfig, loadEnv} from 'vite'
import vue from '@vitejs/plugin-vue'
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
import { resolve } from "path"; 
// import { VUE_APP_BASE_API} from "./config/config"
export default defineConfig(({ mode, command })=> {
  // const env = loadEnv(mode, process.cwd());
  return {
    define: {
      'process.env': {
        NODE_ENV: process.env.NODE_ENV,
      }
    },
    server: {
			// 服务器主机名，如果允许外部访问，可设置为 "0.0.0.0"
			host: "0.0.0.0",
			port: 20300,
			open: true,
			cors: true,
			// 跨域代理配置
			proxy: {
        "/api": {
					target: "http://123.249.22.233:30773", // easymock
					// target: "https://www.fastmock.site/mock/f81e8333c1a9276214bcdbc170d9e0a0", // fastmock
					changeOrigin: true,
					// rewrite: path => {console.log(path,44)},
          logLevel: 'info', // 代理的地址是否显示
				}
			}
		},
    resolve: {
      // https://cn.vitejs.dev/config/#resolve-alias
      alias: {
        // 设置路径
        '~': resolve(__dirname, './'),
        // 设置别名
        '@': resolve(__dirname, './src')
      },
      // https://cn.vitejs.dev/config/#resolve-extensions
      extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
    },
    plugins: [
			vue(),
      	// * 使用 svg 图标
			createSvgIconsPlugin({
				iconDirs: [resolve(process.cwd(), "src/assets/icons/svg")],
				symbolId: "icon-[dir]-[name]"
			}),
		],
  }

  
})
